fix(jdbc-v2): render array contents for named tuples - #3046
Conversation
Fixes ClickHouse#3045. Render nested JDBC Array values with deep formatting so array-of-tuple results are readable to clients that use ResultSet#getObject().
|
@claude review |
|
Claude finished @mshustov's task in 4m 7s —— View job Review: fix(jdbc-v2): render array contents for named tuples
Findings (ordered by severity)1. The output format is a one-way compatibility decision — confirm
If readable-but-approximate output is the intended contract (which is a defensible reading of #3045 — the goal is fixing 2.
3.
4. New single-test integration class instead of an existing home. (style, minor)
What's good
Docs
Tests runI could not run Maven locally (the Summary
Verdict: --- · Branch |
| */ | ||
| @Override | ||
| public String toString() { | ||
| return Arrays.deepToString(array); |
There was a problem hiding this comment.
this can be on someones hot path and will result performance degradation.
All rendering such kind should be done by standalone class. It would be more safe and useful.
Besides here we may not control form of the result so approach will be useful only for some cases.
please implement Array to string formatter if needed.
|
@014-code |
…into fix/3045-jdbc-array-tuple-display
Remove the deep Array.toString() traversal and its tests pending a defined JDBC display contract.
Thank you for the clarification. I have withdrawn the I also merged the latest I will close this PR for now. The original behavior in #3045 needs further investigation and a separately agreed approach before introducing any array or tuple display formatting. |
Summary
Arrayvalues display their nested contents.Array(Tuple(...))values with named tuple elements.java.sql.Arrayreturn type andgetArray()behavior.CHANGELOG.md.Problem
When JDBC v2 returned an array containing a named tuple, clients such as IntelliJ IDEA could display the value as:
com.clickhouse.jdbc.types.Array@54c3b772
For example:
SELECT [('550e8400-e29b-41d4-a716-446655440000')::Tuple(id UUID)];
The actual contents were available through
java.sql.Array#getArray(), but the JDBC wrapper inheritedObject#toString(), which produced an unreadable class name and identity hash.Fixes #3045.
Changes
com.clickhouse.jdbc.types.Array#toString()now uses deep array formatting viaArrays.deepToString(...).The value is now rendered as:
[[550e8400-e29b-41d4-a716-446655440000]]
Nested arrays and tuple values are also rendered correctly.
Compatibility
No public API signatures, JDBC return types, or array contents were changed.
This change only improves the textual representation returned by
com.clickhouse.jdbc.types.Array#toString().Tests
Added:
ArrayTest#testToStringForArrayOfNamedTuplesArray(Tuple(id UUID)).ArrayTupleIntegrationTest#testArrayOfNamedAndUnnamedTuplesToStringResultSet#getObject()returnsjava.sql.Array.toString()matches the contents returned byArray#getArray().